#include <iostream>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <vector>
#include <cstdio>
#include <cmath>
#define LL long long
#define nextLine() {int c = 0; while ((c = getchar()) != EOF && c != 10);}
#define sqr(a) ((a) * (a))
#define fill(a, c) memset(a, c, sizeof a)
#define ldb long double
#define sgn(a) ((a) > eps ? 1 : -1)
const ldb eps = 1e-9;
const ldb pi = fabs(atan2(0.0, -1.0));
const int INF = 1 << 28;
const LL LINF = 1ll << 50;
const ldb LDINF = 1e70;
const ldb cos3 = cos(pi / 3);
const ldb sin3 = sin(pi / 3);
using namespace std;
#define file "a"


map <string, int> id;
int all;

int find(string s)
{
	if (id.find(s) == id.end()) 
	{
		id[s] = all++;
		return all - 1;
	}
	return id[s];
}

int d[23][23];
LL c[3];
int n;


void Load()
{
	cin >> n;
	int i;
	string s, t, like;
	find((string)("Anka"));
	find((string)"Chapay");
	find((string)"Cleo");
	find((string)"Troll");
	find((string)"Dracul");
	find((string)"Snowy");
	find((string)"Hexadecimal");
	for (i = 0; i < n; i++)
	{
		cin >> s >> like >> t;
		d[find(s)][find(t)] = 1;
	}
	cin >> c[0] >> c[1] >> c[2];
}

vector <int> used[3];
LL res;
int diff;
int sat_res, sat;

void go(int i)
{
	if (i == all)
	{
		if (used[0].size() == 0 || used[1].size() == 0 || used[2].size() == 0) return;
		int sat = 0;
		LL mx = -LINF, mn = LINF; 
		for (int j = 0; j < 3; j++)
		{
			LL x = c[j];
			LL y = used[j].size();
			for (int k = 0; k < used[j].size(); k++)
			{
				for (int l = 0; l < used[j].size(); l++)
				{
					sat += d[used[j][k]][used[j][l]];
				}
			}
			mx = max(mx, x / y);
			mn = min(mn, x / y);
		}
		if (mx - mn < res || mx - mn == res && sat > sat_res)
		{
			res = mx - mn;
			sat_res = sat;
		}
		return;
	}
	for (int j = 0; j < 3; j++)
	{
		used[j].push_back(i);
		go(i + 1);
		used[j].pop_back();
	}
}

void Solve()
{
	res = LINF;
	sat_res = 0;
	go(0);
	cout << res << " " << sat_res;

}

int main()
{
	#ifndef ONLINE_JUDGE
	freopen(file".in", "rt", stdin);
	freopen(file".out", "wt", stdout);
	#endif
	Load();
	Solve();
	return 0;
}